<?php

class ListsSectionsIcons extends ControllerAdmin_Base
{
	public function __construct($section) {
		$this->section = $section;
		$this->common_vars  = Registry::get("common_vars");
	}	
	public final function init() {}	
	public function out()
	{
		$r =& Registry::get("MDB")->query("SELECT `ID`,`Parent`,`Name`,`Sys_name` FROM ".DB_STRUCTURE." WHERE `Parent`='".$this->common_vars["structure_id"]."' ORDER BY `Por`;");
		if (PEAR::isError($r)) {
			die($r->getMessage().' ::: '.$r->getUserInfo());
		}
		if($r->numRows())
		{
			$i = 0;
			while($p = $r->fetchRow(MDB2_FETCHMODE_ASSOC))
			{			
				$path_ico = '/img/module_ico/'.$p["sys_name"].'.gif';
				if(file_exists(TEMPLATE_ADMIN.$path_ico)) {
					$arr[$i]["path_ico"] = $path_ico;					
				}
				else {
					$arr[$i]["path_ico"] = '';
				}
				$arr[$i]["name"] = $p["name"];
				$arr[$i]["id"] = $p["id"];
				$arr[$i]["parent"] = $p["parent"];
				$i++;
			}
			Registry::get("smarty")->assign(array('ARRAY' => $arr));
			return Registry::get("smarty")->fetch(TEMPLATE_ADMIN.$this->common_vars["controller_template"], Registry::get("cache_id"));			
		}
	}
}

$controller = new ListsSectionsIcons($section);
$ob_admin_out = $controller->out();

?>